package com.liukai.aspect;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class TxAspect {
    @Before("execution(* com.liukai.service.*.*(..))")
    public void beginTransaction() {
        System.out.println("begin Transaction");
    }
    @AfterReturning("execution(* com.liukai.service.*.*(..))")
    public void commitTransaction() {
        System.out.println("commit Transaction");
    }
    @AfterThrowing("execution(* com.liukai.service.*.*(..))")
    public void rollbackTransaction() {
        System.out.println("rollback Transaction");
    }
}
